//
//  SpotAddressCell.swift
//  swiftProject
//
//  Created by ZhangSai on 2021/7/5.
//

import UIKit

class SpotAddressCell: UITableViewCell {

    @IBOutlet weak var nameLab: UILabel!
    @IBOutlet weak var addressLab: UILabel!
    @IBOutlet weak var lineView: UIView!
    @IBOutlet weak var iconImgV: UIImageView!
    @IBOutlet weak var iconLab: UILabel!
    @IBOutlet weak var bgView: UIView!
    @IBOutlet weak var iconImgLab: UILabel!
    @IBOutlet weak var addressListBtn: UIButton!
    
    typealias SpotAddressCellBlock = () -> Void
    var spotAddressCellBlock : SpotAddressCellBlock!
    
    override func awakeFromNib() {
        super.awakeFromNib()
        self.contentView.backgroundColor = UIColor.init(hexString: "#F3F3F3")
        self.bgView.layer.masksToBounds = true
        self.iconImgLab.layer.masksToBounds = true
        self.iconImgLab.layer.cornerRadius = 8
        
        self.bgView.layer.shadowColor = UIColor.init(red: 0, green: 0, blue: 0, alpha: 0.2).cgColor
        self.bgView.layer.shadowOffset = CGSize.init(width: 0, height: 1)
        self.layer.shadowOpacity = 1
        self.layer.shadowRadius = 2
        self.layer.cornerRadius = 5
        self.iconLab.text = ZslanguageTool.sharedLanguageTool().getIanguageWithKey(key: LanguageHeader.WL_lookExpress) + " "
    }

    override func setSelected(_ selected: Bool, animated: Bool) {
        super.setSelected(selected, animated: animated)

        // Configure the view for the selected state
    }
    
    func setValueWithClientInfoModel(InfoMode:AddressModel,addressType:SpotAddressType) {
        if addressType == SpotAddressType.SpotAddressSentType {
            iconImgLab.backgroundColor = UIColor.init(hexString: "#2C2C2C")
            iconImgLab.text = ZslanguageTool.sharedLanguageTool().getIanguageWithKey(key: LanguageHeader.WL_spot_sendOrder)
            lineView.isHidden = true
        } else if addressType == SpotAddressType.SpotAddressReceiveType {
            iconImgLab.backgroundColor = UIColor.init(hexString: "#FFD10A")
            iconImgLab.text = ZslanguageTool.sharedLanguageTool().getIanguageWithKey(key: LanguageHeader.WL_spot_collectOrder)
            lineView.isHidden = false
        }
        if InfoMode.name.count > 0 {
            nameLab.text = InfoMode.name + InfoMode.phone
        } else {
            if addressType ==  SpotAddressType.SpotAddressSentType{
                self.nameLab.text = ZslanguageTool.sharedLanguageTool().getIanguageWithKey(key: LanguageHeader.WL_spot_fromSender)
            } else {
                self.nameLab.text = ZslanguageTool.sharedLanguageTool().getIanguageWithKey(key: LanguageHeader.WL_spot_sendWhere)
            }
        }
        if InfoMode.detailAddress.count > 0 {
            self.addressLab.text = InfoMode.detailAddress
        } else {
            if addressType ==  SpotAddressType.SpotAddressSentType{
                self.addressLab.text = ZslanguageTool.sharedLanguageTool().getIanguageWithKey(key: LanguageHeader.WL_spot_write_sendMsg)
            } else {
                self.addressLab.text = ZslanguageTool.sharedLanguageTool().getIanguageWithKey(key: LanguageHeader.WL_spot_write_collectMsg)
            }
        }
    }
    
    
    @IBAction func clickAdressBtn(_ sender: UIButton) {
        if (spotAddressCellBlock != nil) {
            spotAddressCellBlock()
        }
    }

}
